//
//  StatusFowrdCell.swift
//  我的微博练习
//
//  Created by zhangguo on 15/10/15.
//  Copyright © 2015年 zhangguo. All rights reserved.
//

import UIKit

class StatusFowrdCell: StatusCell {
    //重写父类属性
    override var statuss: Status?{
        didSet{
            let name = statuss?.retweeted_status?.user?.name ?? ""
            let text = statuss?.retweeted_status?.text ?? ""

           forwardLabel.text = "@" + name + ":" + text
        }
    }

    //设置界面
    override func setupUI() {
        super.setupUI()
        
        //添加控件
        contentView.insertSubview(backButton, belowSubview: pictureImage)
        contentView.insertSubview(forwardLabel, aboveSubview: backButton)
        
        //设置布局
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size:nil,offset: CGPoint(x: -statusCellControlMargin, y: statusCellControlMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        //标签布局
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: statusCellControlMargin, y: statusCellControlMargin))
        
        //配图
        let cont = pictureImage.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: statusCellControlMargin))
        pictureWidthCont = pictureImage.ff_Constraint(cont, attribute: NSLayoutAttribute.Width)
        pictureHightCont = pictureImage.ff_Constraint(cont, attribute: NSLayoutAttribute.Height)
        pictureTopCONT = pictureImage.ff_Constraint(cont, attribute: NSLayoutAttribute.Top)
    }
    
 //懒加载控件
    private lazy var backButton: UIButton = {
        let but = UIButton()
        but.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        
        return but
    }()
    
    private lazy var forwardLabel: UILabel = {
        
        let label =  UILabel(Color: UIColor.darkGrayColor(), fontSize: 14)
        label.numberOfLines = 0
        label.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * statusCellControlMargin
        
        return label
    }()
    

}
